
class MatchInfo:
    """
    足球比赛信息解析类，用于解析和封装足球赛事数据。

    字段说明：
    - match_id: 比赛ID
    - league_name: 联赛名称（如国际友谊、亚洲预选等）
    - league_code: 联赛代码
    - home_team: 主队名称
    - away_team: 客队名称
    - match_time: 比赛时间（格式：YYYY-MM-DD HH:MM:SS）
    - status: 比赛状态
    - odds: 赔率信息
    - handicap: 让球盘口
    - score: 比分
    - country: 国家
    - url: 比赛详情链接
    - other_info: 其他附加信息
    """

    def __init__(self, data):
        self.match_id = data[0]
        self.league_name = data[2]
        self.league_code = data[3]
        self.home_team = data[5]
        self.away_team = data[7]
        self.match_time = data[9]
        self.status = data[10]
        self.odds = data[11]
        self.handicap = data[12]
        self.score = data[13]
        self.country = data[14]
        self.url = data[15]
        self.other_info = data[16] if len(data) > 16 else ""

    def __str__(self):
        return f"MatchInfo(match_id={self.match_id}, league_name='{self.league_name}', " \
               f"home_team='{self.home_team}', away_team='{self.away_team}', " \
               f"match_time='{self.match_time}')"

    def to_dict(self):
        """将对象转换为字典格式"""
        return {
            'match_id': self.match_id,
            'league_name': self.league_name,
            'league_code': self.league_code,
            'home_team': self.home_team,
            'away_team': self.away_team,
            'match_time': self.match_time,
            'status': self.status,
            'odds': self.odds,
            'handicap': self.handicap,
            'score': self.score,
            'country': self.country,
            'url': self.url,
            'other_info': self.other_info
        }


def parse_match_data(data_list):
    """
    解析比赛数据列表

    Args:
        data_list: 包含比赛数据的列表

    Returns:
        list: MatchInfo对象列表
    """
    matches = []
    for data in data_list:
        try:
            match_info = MatchInfo(data)
            matches.append(match_info)
        except Exception as e:
            print(f"解析失败: {e}")
            continue
    return matches


# 示例使用
if __name__ == "__main__":
    # 假设A数组是原始数据
    # 这里只展示部分数据解析示例
    sample_data = A[46]  # 例如取第46个比赛数据
    match = MatchInfo(sample_data)
    print(match)

    # 批量解析
    all_matches = parse_match_data(A[46:50])  # 解析前几个比赛
    for match in all_matches:
        print(match.to_dict())